using System;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace AvaloniaDataGridDemo.ViewModels;

public partial class MainPageViewModel : ObservableObject
{
    private int _count;

    [ObservableProperty] private string _context;

    public ObservableCollection<Item> Orders { get; } = new();

    [RelayCommand]
    void OnUpdate()
    {
        Context = $"{_count++}";
    }

    public MainPageViewModel()
    {
        Context = "test";
        for (var i = 0; i < 60; i++)
        {
            Orders.Add(new Item
            {
                State = "工作中...",
                SerialNo = i + 1,
                AuthorId = 20424666,
                OrderId = Guid.NewGuid().ToString(),
                WorkerId = Guid.NewGuid().ToString(),
                WorkerCount = Random.Shared.Next(100),
                StateCount = Random.Shared.Next(100),
                JoinTime = i + "分钟",
                StartDateTime = DateTime.Now,
                ExpDateTime = DateTime.Now,
            });
        }
    }
}

public class Item
{
    public string? State { get; set; }

    public string? OrderId { get; set; }

    public string? WorkerId { get; set; }
    public string? JoinTime { get; set; }
    public DateTime StartDateTime { get; set; }
    public DateTime ExpDateTime { get; set; }
    public int WorkerCount { get; set; }

    public int StateCount { get; set; }
    public int SerialNo { get; set; }

    public long AuthorId { get; set; }
}